#!/bin/bash
#Script to run woof (one file at a time network sharing)
# from arox (Absolute's rox-filer spinoff)

DIALOG=Xdialog
# first make sure we have one file or folder only:
if [ ! -z "$2" ]; then
	$DIALOG --timeout 5 --rc-file /usr/share/pixmaps/colorboxDOH.rc  --icon /usr/share/pixmaps/woof_icon.xpm  --title "WOOF!" \
		--msgbox "\nOne file or folder at a time, \nplease\n" 0 0
	exit 1
fi

# make sure we were passed information to work on:
if [ -z "$1" ]; then
	$DIALOG --timeout 5 --rc-file /usr/share/pixmaps/colorboxDOH.rc  --icon /usr/share/pixmaps/woof_icon.xpm  --title "WOOF!" \
		--msgbox "\nNo file name to share was passed, \nsorry\n" 0 0
	exit 1
fi

# make sure woof script is installed:
if ! [ -x "$(command -v woof)" ]; then
	$DIALOG --timeout 5 --rc-file /usr/share/pixmaps/colorboxDOH.rc  --icon /usr/share/pixmaps/woof_icon.xpm  --title "WOOF!" \
		--msgbox "\nWoof file sharing script cannot be found, \nsorry\n" 0 0
	exit 1
fi

# Directory or file:
if [[ -d "$1" ]]; then
	xterm -T "woof folder: $1" -n woof -e woofpauser woof -Z -p 9876 \"$1\" &
	exit 0
fi

if [[ -f "$1" ]]; then
	xterm -T "woof file: $1" -n woof -e woofpauser woof -p 9876 \"$1\" &
	exit 0
fi


